package correlationOfSalAndExp;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class CorrelationDriver {

    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();

        Job job = Job.getInstance(conf);
        job.setJarByClass(CorrelationDriver.class);

        job.setMapperClass(CorrelationMapper.class);
        job.setReducerClass(CorrelationReducer.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        Path input = new Path("input/jobData.csv");
        Path output = new Path("output/CorrelationOfSalAndExp");

        FileInputFormat.addInputPath(job,input);
        FileOutputFormat.setOutputPath(job,output);

        FileSystem fs = FileSystem.get(conf);

        if ( fs.exists(output) ){
            fs.delete(output,true);
        }

        System.exit( job.waitForCompletion(true) ? 0 : 1 );
    }
}

